package com.wc.alorithm_blue_bridge._简单题.Q7936;

/**
 * @Author congege
 * @Description
 * @Date Created in 2023/12/19-23:12
 */
public class Main {
    public static void main(String[] args) {
        long num = 1;
        int idx = 0;
        for (long i = num; i <= 1000000; i++) {
            if (isEq(Long.toBinaryString(i),Long.toOctalString(i))){
                idx++;
                if (idx==23){
                    System.out.println(i);
                    return;
                }
            }
        }
    }

    public static boolean isEq(String m, String n) {
        int num1 = 0;
        int num2 = 0;
        for (char c : m.toCharArray()) {
            if (c == '1') {
                num1++;
            }
        }
        for (char c : n.toCharArray()) {
            if (c == '1') {
                num2++;
            }
        }
        return num1 == num2;
    }
}
